package com.apes.framework.condition;

import com.apestech.formwork.condition.ConditionUtil;
import com.apestech.framework.db.SqlSession;
import com.apestech.framework.json.JSONArray;
import com.apestech.framework.json.JSONObject;
import com.apestech.framework.xml.condition.modul.Condition;
import com.apestech.framework.xml.condition.modul.Dimension;

import java.util.ArrayList;

/**
 * @author hup
 * @create 2019-09-25-17:10
 */
public class StrategyField {
    private JSONArray result;
    private String dimensionId;
    private SqlSession session;
    private Condition condition;
    private Dimension dimension;

    public StrategyField(String conditionId, String dimensionId, SqlSession session) throws Exception {
        this.dimensionId=dimensionId;
        this.session=session;
        this.condition= ConditionUtil.getCondition(conditionId, session);
        ArrayList<Dimension> list=this.condition.getDimension();

    }

    private JSONObject getFormControl() throws Exception {
        JSONObject map=new JSONObject();
        map.put("bodyStyle","{'padding':0,'margin-top':'-16px'}");
        map.put("genre", "form");
        map.put("id","a");
        map.put("title","");
        map.put("type","panel");
        map.put("fields",null);  //jsonarray
        return map;
    }

    private JSONArray getControls() throws Exception {
        JSONArray fields=new JSONArray();

        return fields;
    }

    private JSONObject getControl() throws Exception {
        JSONObject map=new JSONObject();
        map.put("hideExpression","false");
        map.put("key", "company");
        map.put("type","select");
        map.put("templateOptions",getOption());
        map.put("lifecycle",getLifecycle());
        return map;
    }

    private JSONObject getOption() throws Exception {
        JSONObject map=new JSONObject();
        map.put("api","cm.corporateCustom.find");
        map.put("label","客户");
        map.put("valueFormatter","value.name");
        return map;
    }

    private JSONObject getLifecycle(){
        JSONObject map=new JSONObject();
        return map;
    }

}
